home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
bbsutil
/
dlx70bbs.zip
/
DLX70SRC.ZIP
/
COM_PAX2.ASM
< prev
next >
Wrap
Assembly Source File
|
1994-01-19
|
41KB
|
1,451 lines
; COM_PAX2.ASM
; Communications Package for the IBM PC, XT, AT, Clones
; Extensively modified for DLX -- not for general use
; 32 line version -- both com/8 and mc/8
; port1 port2
; 3f8 2f8 com1=line1 / com2=line2
; 3f8 other com1=line1 / com2 com/x lines 2-9
; other 2f8 com1 com/x lines 1-8 / com2=line9
; other other com1 com/x lines 1-8,17-24 / com2 com/x lines 9-16,25-32
; DLX Bulletin Board System V7.0
; FREEWARE NOTICE
; DLX V7.0 is placed in the public domain by its author, Richard Gillmann.
; Anyone who wishes to may run the program, copy it, or modify it for
; any purpose, including commercial gain.
; o Special features for BBSes
; o Uses MS Pascal calling conventions
; o Supports all serial ports simultaneously
; o All speeds to 19200 baud
; o Compatible with PC, XT, AT (not PCjr or PS/2 alas)
; o Built in XON/XOFF flow control
; o I/O buffers not in DGROUP
; boolean constants
true equ 1 ; what MS Pascal
false equ 0 ; believes
; params
wrapcol equ 74 ; hard wrap at this column
nlines equ 32 ; number of lines
; maximum buffer sizes
r_size equ 360 ; size of receive buffers
s_size equ 180 ; size of transmit buffers
; ascii
bs equ 8 ; backspace
tab equ 9 ; tab
lf equ 10 ; linefeed
cr equ 13 ; carriage return
del equ 127 ; del
; interrupt numbers
int_com1 equ 0ch ; com1: from 8259
int_com2 equ 0bh ; com2: from 8259
; 8259 ports
inta00 equ 20h ; 8259a port, a0 = 0
inta01 equ 21h ; 8259a port, a0 = 1
; com1: level 4
irq4 equ 2*2*2*2 ; 8259a ocw1 mask, m4=1, a0=0
nirq4 equ not irq4 and 0ffh ; complement of above
eoi4 equ 4 or 01100000b ; 8259a ocw2 specific irq4 eoi, a0=0
; com2: level 3
irq3 equ 2*2*2 ; 8259a ocw1 mask, m3=1, a0=0
nirq3 equ not irq3 and 0ffh ; complement of above
eoi3 equ 3 or 01100000b ; 8259a ocw2 specific irq3 eoi, a0=0
; flow control characters
control_q equ 11h ; xon
control_s equ 13h ; xoff
; misc.
control_c equ 3h ; control c
control_o equ 0fh ; control o
dos equ 21h ; dos function calls
pushem macro
push bp
mov bp,sp
push ds
mov ax,data2
mov es,ax
endm
popem macro
pop ds
pop bp
endm
;
; rom bios data area
;
rbda segment at 40h
org 6ch
timer_low dw ? ; low word of bios timer count
rbda ends
;
; table for each serial port
;
sp_tab struc
port db ? ; 1..nlines
; buffer displacements
di_tdata dw ? ; offset to our part of tdata
di_rdata dw ? ; offset to our part of rdata
; attributes
baud_rate dw ? ; 300 to 9600 baud ok
parity db ? ; n(one) o(dd) e(ven) s(pace) m(ark)
stop_bits db ? ; 1, 2
echo_state db ? ; 1=echo 0=no echo
chars_this_line db ? ; chars on this line so far
woscol db ? ; wrap on space column
; flow control state
host_off db ? ; host xoffed (1=yes,0=no)
pc_off db ? ; pc xoffed (1=yes,0=no)
cancelled db ? ; flag if control c seen
skipped db ? ; flag if control o seen
timeout dw ? ; timeout clock
warnout db ? ; warning flag
binary db ? ; xmodem flag
soft_cr db ? ; soft carriage return (1=yes,0=no)
; 8250 ports
datreg dw ? ; data register
ier dw ? ; interrupt enable register
iir dw ? ; interrupt identification register
lcr dw ? ; line control register
mcr dw ? ; modem control register
lsr dw ? ; line status register
msr dw ? ; modem status register
; buffer pointers
start_tdata dw ? ; index to 1st character in xmit buf
end_tdata dw ? ; index to 1st free space in xmit buf
start_rdata dw ? ; index to 1st character in rec buf
end_rdata dw ? ; index to 1st free space in rec buf
; buffer counts
size_tdata dw ? ; number of characters in x-mit buffer
size_rdata dw ? ; number of characters in rec. buffer
sp_tab ends
; sp_tab equates
; we have to use these because of problems with struc
dll equ datreg ; low divisor latch
dlh equ ier ; high divisor latch
data2 segment public 'DATA'
; i/o buffers (not in DGROUP)
tdata db nlines*s_size dup(?) ; send buffers
rdata db nlines*r_size dup(?) ; receive buffers
data2 ends
extrn to_warn:word,to_kill:word,hostecho:byte,dcd_ok:byte
extrn ps2mc8:byte
public com1_port,com2_port,status_port1,status_port2,bits8,eskape
data segment public 'DATA'
com1_port dw 3f8h ; port address / int4
com2_port dw 2f8h ; port address / int3
status_port1 dw 140h ; digiboard status / int4
status_port2 dw 140h ; digiboard status / int3
old_com_off1 dw ? ; old handler's offset level 4
old_com_seg1 dw ? ; old handler's segment level 4
old_com_off2 dw ? ; old handler's offset level 3
old_com_seg2 dw ? ; old handler's segment level 3
temp dw 0 ; temp used by echo_com
bpp db 8 ; bytes per port in i/o address space
bits8 db 7fh ; mask applied to incoming characters
div50 dw 2304 ; pc/xt/at divisor for 50 baud
area_length dw type sp_tab ; length of param block
current_area dw area1 ; currently selected area
channel db 0 ; current mc/8 channel
; data areas for each port
atabl macro x
area&x sp_tab <x,(x-1)*s_size,(x-1)*r_size>
endm
y = 0
rept nlines
y = y + 1
atabl %y
endm
; filter for incoming characters (0 means ignore them)
; disallows certain characters, also strips parity
filter db 3 dup(0)
db 7fh ; control-c
db 4 dup(0)
db 7fh ; bs
db 7fh ; tab
db 7fh ; lf
db 2 dup(0)
db 7fh ; cr
db 7fh ; double note for music
db 7fh ; control-o
db 0
db 7fh ; control-q
db 0
db 7fh ; control-s
db 7 dup(0)
eskape db 0 ; escape
db 4 dup(0)
db 95 dup(7fh) ; printable ascii
db 7fh ; del
db 128 dup(0ffh) ; upper chars for europe
tabsiz db 8 ; tab spacing
data ends
dgroup group data
auxhndlr segment 'CODE'
assume cs:auxhndlr,ds:dgroup,ss:dgroup,es:data2
; 8259
public save_com ; save old interrupt vector
public installc ; install our interrupt vector
public restorec ; restore old interrupt vector
; 8250
public select_port ; select communications port
public open_com ; initialize port
public close_com ; turn off interrupts from com port
public dtr_off ; turn off dtr
public dtr_on ; turn on dtr
public rlsd ; return rlsd (still on-line if true)
public warning ; return true if time to warn of timeout
public unwarn ; cancel timeout warning
public r_count ; return number of characters in input buffer
public receive ; read next character in input buffer
public s_free ; return no. of free bytes in output buffer
public s_working ; return no. of chars waiting in output buffer
public send ; write a character to output buffer
public echo_com ; echo to sender again
public purge_com ; empty buffers
public unskip_com ; stop skipping
public cancelled_com ; have we been control c-ed?
public force_cancel ; simulate control-C
public skipped_com ; have we been control o-ed?
public wrap ; set wrap column
public binary_mode ; toggle binary mode
public was_soft ; was that a soft carriage return?
page
;
; internal buffer routines
; at this point, si is already set up
; gst = get from start of tdata (to al)
; gsr = get from start of rdata (to al)
; pet = put (from al) to end of tdata (preserves al)
; per = put (from al) to end of rdata (preserves al)
; pst = put (from al) to start of tdata (preserves al)
; to be safe, call these with interrupts off
;
gst proc near ; *call with interrupts off*
mov al,0 ; in case of underflow
cmp size_tdata[si],0 ; any characters?
je gst_x ; jump if not
mov bx,start_tdata[si] ; bx points to next char. to be sent
mov di,di_tdata[si]
mov al,tdata[di][bx] ; get data from buffer
inc bx ; increment start_tdata
cmp bx,s_size ; see if gone past end
jb gst_1 ; if not then skip
mov bx,0 ; reset to beginning
gst_1: mov start_tdata[si],bx ; save start_tdata
dec size_tdata[si] ; one less character in x-mit buffer
gst_x: ret ; done
gst endp
;
gsr proc near
mov ax,0 ; in case of underflow
cmp size_rdata[si],0 ; any character